import java.awt.*;

public class GetPoint {
    public int[] getPoint() throws Exception {
        Robot robot = new Robot();
        robot.delay(2500);
        PointerInfo pinfo = MouseInfo.getPointerInfo();
        Point p = pinfo.getLocation();
        int mx = (int) p.getX();
        int my = (int) p.getY();
        Color mouseRGB = robot.getPixelColor(mx, my);
        int R = mouseRGB.getRed();
        int G = mouseRGB.getGreen();
        int B = mouseRGB.getBlue();
        int[] array = new int[]{mx, my, R, G, B};
        return array;
    }

    public static void main(String[] args) {
        GetPoint getPoint = new GetPoint();
        int[] xyrgb = null;
        try {
            xyrgb = getPoint.getPoint();
        } catch (Exception e) {
            e.printStackTrace();
        }
        for (int i = 0; i < xyrgb.length; i++)
            System.out.print(xyrgb[i] + " ");
    }
}
